#!/usr/bin/env python

import sys
import os
import difflib

def run(command):
    return os.popen(command).read()


def getState(product):
    stateFile = file('../../subscribe/' + product + '.state', 'rb')
    state = stateFile.readlines()
    stateFile.close()
    return state

def main(args=None):
    if args == None:
        args = sys.argv[1:]




    thisDir = os.path.basename(os.path.abspath('.'))
    oldState = getState(thisDir)

    print run('ant subscribe')

    newState = getState(thisDir)
    
    print ''.join([d for d in difflib.ndiff(oldState, newState) if d[0] in '+-'])
    
    return 0


if __name__ == '__main__':
    sys.exit(main())

